package com.sns;

import com.sns.dao.UserInfoDao;
import com.sns.model.UserInfo;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@SpringBootApplication
//@EnableAutoConfiguration
@MapperScan("com.sns.dao")
public class RrApplication extends SpringBootServletInitializer {
    private static Logger logger=LoggerFactory.getLogger(RrApplication.class);
    @Autowired
    private UserInfoDao userInfoDao;

    @Override
    protected SpringApplicationBuilder  configure(SpringApplicationBuilder application){
        return application.sources(RrApplication.class);
    }

    @RequestMapping("/")
    String home(){
        logger.info("info");
        logger.error("error");
        List<UserInfo> lu=userInfoDao.getUsers();
        return lu.get(0).toString();
    }

    public static void main(String[] args) {
        logger.info("项目路径："+RrApplication.class.getResource("/").getPath());
        SpringApplication.run(RrApplication.class);
    }
}
